home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASCALL / RANDPIX / RANDPIXL.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-22  |  1KB  |  65 lines

  1. program randpixl;
  2. uses
  3.      crt,graph;
  4.  
  5. procedure setupgraph(Gd,Gm:integer);
  6. begin
  7.      InitGraph(Gd,Gm,'c:\tp\bgi');
  8.      if GraphResult<>grOk then halt;
  9.      cleardevice;
  10. end;
  11.  
  12.  
  13. function cycle:boolean;
  14. var
  15.      a:byte;
  16.  
  17.   procedure go;
  18.   var
  19.        x,y:integer;
  20.        color,radius:word;
  21.   begin
  22.        delay(80);
  23.        randomize;
  24.        randseed:=random(getmaxx div 2);
  25.        x:=random(getmaxx);
  26.        randseed:=random(getmaxy div 2);
  27.        y:=random(getmaxy);
  28.        randseed:=random(getmaxcolor);
  29.        color:=random(getmaxcolor)+(getmaxcolor div 2);
  30.        randseed:=random(getmaxy div 2);
  31.        radius:=random(getmaxy div 2);
  32.  
  33.        setcolor(color);
  34.        circle(x,y,radius);
  35.   end;
  36.   function test:byte;
  37.     function inkey:char;
  38.     var
  39.          d:char;
  40.     begin
  41.          if keypressed then inkey:=readkey else inkey:=chr(8);
  42.     end;
  43.   begin
  44.        case upcase(inkey) of
  45.             'S',#27: test:=1;
  46.             'A': test:=2;
  47.             else test:=0;
  48.        end;
  49.   end;
  50. begin
  51.      repeat
  52.           go;
  53.           a:=test;
  54.      until a>0;
  55.      cycle:=(a=1);
  56. end;
  57.  
  58. begin
  59.      setupgraph(vga,vgahi);
  60.      repeat
  61.           cleardevice;
  62.      until cycle;
  63. end.
  64.  
  65.